package com.vhans.bapi.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.vhans.core.web.controller.BaseController;
import com.vhans.core.web.model.Result;
import com.vhans.db.model.dto.ConditionDTO;
import com.vhans.db.model.vo.request.RequestVO;
import com.vhans.db.service.ICRequestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 请求Controller控制器
 *
 * @author vhans
 * @date 2023-05-21
 */
@Api(tags = "请求模块")
@RestController
@RequestMapping("/request")
public class RequestController extends BaseController {
    @Autowired
    private ICRequestService requestService;

    /**
     * 查询用户的好友请求列表
     *
     * @return {@link RequestVO} 请求列表
     */
    @SaCheckLogin
    @ApiOperation(value = "查询用户的好友请求列表")
    @GetMapping("/list/friend")
    public Result<List<RequestVO>> listFR() {
        return Result.success(requestService.selectUserRequestVOList());
    }

    /**
     * 查询我的请求列表
     *
     * @return {@link RequestVO} 请求列表
     */
    @SaCheckLogin
    @ApiOperation(value = "查询用户的好友请求列表")
    @GetMapping("/list/i")
    public Result<List<RequestVO>> listIR() {
        return Result.success(requestService.selectIRequestVOList());
    }

    /**
     * 查询请求消息
     *
     * @param condition 条件
     * @return {@link RequestVO} 请求列表
     */
    @SaCheckLogin
    @ApiOperation(value = "查询请求消息")
    @GetMapping("/getRequest")
    public Result<List<RequestVO>> getRequest(ConditionDTO condition) {
        return Result.success(requestService.selectRequestVOList(condition));
    }
}
